package fields;

import translate.Translate;
import entities.Inventory;
import gstd.Player;

public class Fleet extends Ownable {

	private final int RENT_1 = 500;
	private final int RENT_2 = 1000;
	private final int RENT_3 = 2000;
	private final int RENT_4 = 4000;

	public Fleet(String name, int price) {
		super(name, price);
	}

	@Override
	public int getRent() {
		int numberOfOwnedFleets = 0;
		if (getOwner() != null)
			numberOfOwnedFleets = ((Inventory) getOwner().getInventory()).getNumberOfFleets();

		int rent;
		switch (numberOfOwnedFleets) {
		case 1:
			rent = RENT_1;
			break;
		case 2:
			rent = RENT_2;
			break;
		case 3:
			rent = RENT_3;
			break;
		case 4:
			rent = RENT_4;
			break;
		default:
			rent = 0;
			break;
		}
		System.out.println("fleet rent: " + rent);
		return rent;
	}

	@Override
	public void landOnField(Player player) {
		buyField(player);
		if (getOwner() != null && getOwner() != player) {
			int rent = getRent();
			player.getInventory().addBalance(-rent);
			super.getOwner().getInventory().addBalance(rent);
		}
	}

	@Override
	public String toString() {
		return super.toString() + Translate.print("Rent: %d - %d ", 500, 4000);
	}
}
